package com.dmx.fw.bean.mapping.pojo;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.CollectionOfElements;

/**
 * Role generated by MyEclipse - Hibernate Tools
 */
@Entity
@Table(name = "SYSTEM_ROLE")
public class Role implements java.io.Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO,generator="role_seq_gen")
	@SequenceGenerator(name="role_seq_gen",sequenceName="SEQ_ROLE")
	private Long id;
	@Temporal(TemporalType.DATE)
	@Column(name = "LAST_UPDATED_TIME")
	private Date lastUpdatedTime;
	@Column(name = "NAME")
	private String name;
	private String remark;
	@Column(name = "CREATED_BY")
	private Operator createdOperator;
	@Temporal(TemporalType.DATE)
	@Column(name = "CREATED_TIME")
	private Date createdTime;
	@Column(name = "LAST_UPDATED_BY")
	private Operator lastUpdatedOperator;

	@ManyToMany(targetEntity = Resc.class)
	@CollectionOfElements
	@JoinTable(name = "SYSTEM_RESC_ROLE", joinColumns = @JoinColumn(name = "ROLE_ID"), 
			inverseJoinColumns = @JoinColumn(name = "RESC_ID"))
	private Set<Resc> rescs = new HashSet<Resc>(0);

	@ManyToMany(targetEntity = Operator.class)
	@CollectionOfElements
	@JoinTable(name = "SYSTEM_OPTR_ROLE", joinColumns = @JoinColumn(name = "ROLE_ID"), 
			inverseJoinColumns = @JoinColumn(name = "OPTR_ID"))
	private Set<Operator> operators = new HashSet<Operator>(0);

	// Constructors

	/** default constructor */
	public Role() {
	}

	/** full constructor */
	public Role(String name, String remark, Operator createdOperator,
			Date createdTime, Operator lastUpdatedOperator, Set rescs,
			Set operators) {
		this.name = name;
		this.remark = remark;
		this.createdOperator = createdOperator;
		this.createdTime = createdTime;
		this.lastUpdatedOperator = lastUpdatedOperator;
		this.rescs = rescs;
		this.operators = operators;
	}

	// Property accessors

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getLastUpdatedTime() {
		return this.lastUpdatedTime;
	}

	public void setLastUpdatedTime(Date lastUpdatedTime) {
		this.lastUpdatedTime = lastUpdatedTime;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Operator getCreatedOperator() {
		return this.createdOperator;
	}

	public void setCreatedOperator(Operator createdOperator) {
		this.createdOperator = createdOperator;
	}

	public Date getCreatedTime() {
		return this.createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public Operator getLastUpdatedOperator() {
		return this.lastUpdatedOperator;
	}

	public void setLastUpdatedOperator(Operator lastUpdatedOperator) {
		this.lastUpdatedOperator = lastUpdatedOperator;
	}

	public Set getOperators() {
		return this.operators;
	}

	public void setOperators(Set operators) {
		this.operators = operators;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Set getRescs() {
		return rescs;
	}

	public void setRescs(Set rescs) {
		this.rescs = rescs;
	}

}